<template>
  <div class="Top">
    <div class="item" @click="changeTop(1)">
      <router-link to="/channel" :class="topIndex==1?'active':''">频道</router-link>
    </div>
    <div class="item" @click="changeTop(2)">
      <router-link to="/partition" :class="topIndex==2?'active':''">分区</router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: "Circles",
  data() {
    return {
      topIndex: 1
    }
  },
  methods: {
    changeTop(index) {
      this.topIndex = index
    },
    getParams() {
      if (this.topIndex==1){
        this.topIndex=2;
      }else {
        this.topIndex=1;
      }
    }
  },

  watch: {
    // 监测路由变化,只要变化了就调用获取路由参数方法将数据存储本组件即可
      '$route':'getParams'
  }

}
</script>

<style scoped>
a {
  text-decoration: none;
  color: #3e3e3e;
}
.router-link-active {
  text-decoration: none;
}
.Top {
  z-index: 999;
  opacity: 1;
  position: fixed;
  top: 0;
  left: 0;
  display: flex;
  justify-items: center;
  width: 100%;
  height: 60px;
  line-height: 60px;
  border-bottom: 1px #cccccc solid;
  background-color: white;
}

.Top .item {
  text-align: center;
  font-size: 16px;
}

.Top .item:nth-child(1) {
  width: 50%;
  font-size: 25px;
}

.Top .item:nth-child(2) {
  width: 50%;
  font-size: 25px;
}

.Top .item .active {
  border-bottom: 3px solid #000;
}

</style>